﻿//
//  HFHttpFactory.h
//  HFBaseLibModule
//
//  Created by Points on 2020/4/3.
//  Copyright © 2020 hfqf123@126.com. All rights reserved.
//  网络请求工厂类，默认使用最新的请求逻辑，派生出的子类会覆盖请求方法，以达到兼容之前来聚财和华体的请求单例及相应请求方法

#import <UIKit/UIKit.h>
#import "HFHttpAbstractFactory.h"

NS_ASSUME_NONNULL_BEGIN

typedef enum : NSUInteger {
    Product,
    DevDomain,
    TestDomain,
    ReleaseDomain,
    JustGetDomain//只是get路径
} enum_domain;

@interface HFHttpFactory : NSObject <HFHttpAbstractFactory>


@property(nonatomic,strong) NSURLSessionTask *task;
@property(nonatomic,copy) NSString           *mDomain;
@property(nonatomic,copy) NSString           *mPath;
@property(nonatomic,copy) NSDictionary       *mPara;
@property(nonatomic,copy) NSString           *mImageName;
@property(nonatomic,copy) NSString           *mFileName;
@property(nonatomic,copy) NSData             *mImage;
@property(nonatomic,copy) NSArray<NSData *>  *mImageArray;

@property(nonatomic,copy) NSString           *mMimeType;

@property(nonatomic,assign) BOOL              needToast;
@property(nonatomic,copy) HFHttpSucceedBlock mSucceedBlock;
@property(nonatomic,copy) HFHttpFailedBlock  mFailedBlock;
@property(nonatomic,copy) COPromise<COTuple *>* promise;
@property (nonatomic, copy)HFHttpDelayBlock delayOperationBlock;

// rsa加密结果
@property (nonatomic, assign) BOOL rsaEncryptResult;

// rsa加密开关
@property (nonatomic, assign) BOOL rsaSwitch;


+ (instancetype)factory;

+ (void)requestSuccessWithTask:(NSURLSessionDataTask *)task
                          body:(NSDictionary *)body
                responseObject:(id)responseObject
                successHandler:(HFHttpSucceedBlock)successHandler
                     needToast:(BOOL)needToast
                     rsaSwitch:(BOOL)rsaSwitch;

+ (void)requestFailureWithTask:(NSURLSessionDataTask *)task
                         param:(NSDictionary *)param
                         error:(NSError *)error
                failureHandler:(HFHttpFailedBlock)failureHandler
                     needToast:(BOOL)needToast;

#pragma mark - coobjc
+ (void)requestSuccessWithTask4Cobjc:(NSURLSessionDataTask *)task
                          body:(NSDictionary *)body
                responseObject:(id)responseObject
                successHandler:(HFHttpSucceedBlock)successHandler
                     needToast:(BOOL)needToast
                     rsaSwitch:(BOOL)rsaSwitch
                             promise:(COPromise<COTuple *>*)promise;

+ (void)requestFailureWithTask4Cobjc:(NSURLSessionDataTask *)task
                               param:(NSDictionary *)param
                               error:(NSError *)error
                      failureHandler:(HFHttpFailedBlock)failureHandler
                           needToast:(BOOL)needToast
                             promise:(COPromise<COTuple *>*)promise;

- (NSString *)hostFileUrl;

- (void)startDelayTimer:(NSURLSessionTask *)task;
@end

NS_ASSUME_NONNULL_END

